Kinetis SDK Demo Applications User Guide  1.0.0-beta
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
fsl_mma8451.c File Reference
#include "fsl_mma8451.h"
#include "i2c_sim.h"
#include <stdio.h>
#include <string.h>

Enumerations

enum  _mma8451_i2c_constants {
  kMMA8451_I2C_Address,
  kMMA8451_I2C_Address_With_SAO_Set
}
 I2C related constants for the MMA8451. More...
 

Functions

uint8_t mma8451_read_register (const mma8451_device_t *device, uint8_t reg_addr)
 Read a single register of the MMA8451. More...
 
int32_t mma8451_write_register (const mma8451_device_t *device, uint8_t reg_addr, uint8_t reg_val)
 Write a single register of the MMA8451. More...
 
int32_t mma8451_init (mma8451_device_t *device, uint8_t i2c_addr, uint32_t baud_kbps)
 Initialize the MMA8451 driver instance. More...
 
int32_t mma8451_get_acceleration (const mma8451_device_t *device, acceleration_t *accel)
 Read the current acceleration values. More...
 

Enumeration Type Documentation

Enumerator
kMMA8451_I2C_Address 
kMMA8451_I2C_Address_With_SAO_Set 

Function Documentation

int32_t mma8451_get_acceleration ( const mma8451_device_t device,
acceleration_t accel 
)
Parameters
devicePointer to a valid device instance structure.
accelPointer to a structure that will be filled in with the current acceleration values for all three axes.
Returns
kStatus_Success or error code.
Return values
kStatus_Success
int32_t mma8451_init ( mma8451_device_t device,
uint8_t  i2c_addr,
uint32_t  baud_kbps 
)
Parameters
deviceDevice driver state structure that will be filled in by this function. It is the responsibility of the caller to provide storage for this structure, and to free that storage when the driver is no longer needed.
isSaoSet
baud_kbps
Returns
kStatus_Success or error code.
Return values
kStatus_Success
kMMA8451_Invalid_I2C_Address_Error
uint8_t mma8451_read_register ( const mma8451_device_t device,
uint8_t  reg_addr 
)
Parameters
devicePointer to a valid device instance structure.
reg_addrAddress of the internal MMA8451 register to read.
Returns
The register's value.
int32_t mma8451_write_register ( const mma8451_device_t device,
uint8_t  reg_addr,
uint8_t  reg_val 
)
Parameters
devicePointer to a valid device instance structure.
reg_addrAddressof the internal MMA8451 register to change the value of.
reg_valNew value for the register.
Returns
kStatus_Success or error code.
Return values
kStatus_Success